# -*- coding;utf-8 -*-
"""
File name : celery_config.py.PY
Program IDE : PyCharm
Create file time: 2023/10/17 8:11
File Create By Author : 朱清闯
"""
# celery_tasks/celery_config.py
# 配置一个 celery_config.py, 存储配置信息, 实现 配置信息 存在于 单独的配置文件中
# 之后在main.py, 让实例对象 app 加载其中的配置

from django.conf import settings

# 代理人：指定redis作为消息队列
celery_broker_config = settings.REDIS_DATABASE['CELERY_BROKER']
broker_password = celery_broker_config.get('PASSWORD', '')
redis_database = settings.REDIS_DATABASE['CELERY_BROKER']
if broker_password:
    backend = f'redis://:{redis_database["PASSWORD"]}@{redis_database["HOST"]}:{redis_database["PORT"]}/{redis_database["DB"]}'
else:
    backend = f'redis://:{redis_database["HOST"]}:{redis_database["PORT"]}/{redis_database["DB"]}'
broker_url = backend


